package vis;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;

import logic.Line;
import logic.PointD;

public class GLine extends Line implements Drawable {
	private Color color = Color.BLACK;
	private Color hlColor = Color.ORANGE;
	private boolean hl = false;
	private boolean visible = true;
	
	private static final Stroke nStroke = new BasicStroke(1.0f); 
	private static final Stroke hStroke = new BasicStroke(2.0f);
	
	public GLine(double x1, double y1, double x2, double y2) {
		super(x1, y1, x2, y2);
	}
	
	public GLine(GPoint p1, GPoint p2) {
		super(p1, p2);
	}

	@Override
	public void draw(Graphics2D g) {
		Stroke s = g.getStroke();
		if(hl)
		{
			g.setStroke(hStroke);
			g.setColor(hlColor);
		}
		else
		{
			g.setStroke(nStroke);
			g.setColor(color);
		}
		g.drawLine((int)p[0].getX(), (int)p[0].getY(), (int)p[1].getX(), (int)p[1].getY());
		g.setStroke(s);
	}

	@Override
	public Color getColor() {
		return color;
	}

	@Override
	public void resetHighlight() {
		hl = false;
	}

	@Override
	public void setColor(Color c) {
		color = c;
	}

	@Override
	public void setHighlight(Color c) {
		hlColor = c;
		hl = true;
	}

	@Override
	public boolean isVisible() {
		return visible;
	}

	@Override
	public void setPosition(double x, double y) {
		}

	@Override
	public void setVisible(boolean vis) {
		visible = vis;
	}

	@Override
	public double getPosX() {
		return 0;
	}

	@Override
	public double getPosY() {
		return 0;
	}

	@Override
	public Color getHighlightColor() {
		return hlColor;
	}

	@Override
	public boolean isHighlighted() {
		return hl;
	}

}
